﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Data;
using System.Data.SqlServerCe;
using System.Linq;
using System.Text;
using MTGenome.MTG;

namespace MTGenome.Gatherer
{
    [Export(typeof(IDatabaseConnection)), PartCreationPolicy(CreationPolicy.Shared)]
    public sealed class DatabaseConnection : IDatabaseConnection
    {
        public DatabaseConnection(string path)
        {
            Connection = new SqlCeConnection(string.Format("Data Source={0}", path));
        }

        public DatabaseConnection()
        {
            Connection = new SqlCeConnection(string.Format("Data Source={0}\\MTGenome.sdf", GathererServer._dataDirectory));
            Readonly = true;
        }

        public IDbConnection Connection
        {
            get;
            private set;
        }

        public bool Readonly
        {
            get;
            private set;
        }
    }
}
